package com.lance.answer.question_answer.xj_new;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import com.lance.answer.dto.XjCourseVideoInfo;
import com.lance.answer.gui.answer.AnswerObject;
import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class TTT {

    public static void main(String[] args) throws Exception {
        String s= "s123123\nsadasd";
        System.err.println(s);
        System.err.println(s.replace("\n",""));

      System.err.println(  new Random().nextInt(10));

        Thread.sleep(1000000);

//        File file1 = new File("f:/tmp");
//
//        //将原文件夹更改为A，其中路径是必要的。注意
//        file1.renameTo(new File("f:/tmp1111111111"));

  //      InputStream inputStream = new FileInputStream("E:\\排名map.txt");


//        for(File file:new File("D:\\新疆一体化视频作业").listFiles()){
//            file.renameTo(new File("D:\\新疆一体化视频作业\\"+mapTmp.get(file.getName())));
//        }

//        for(File file:new File("D:\\新疆一体化平时作业").listFiles()){
//            file.renameTo(new File("D:\\新疆一体化平时作业\\"+mapTmp.get(file.getName())));
//        }

//        for(File file:new File("D:\\新疆一体化2\\CourseInfoDeal").listFiles()){
//            String name = file.getName();
//            name = name.substring(0,name.length()-5);
//            System.out.println(name);
//            file.renameTo(new File("D:\\新疆一体化2\\CourseInfoDeal\\"+mapTmp.get(name)+".json"));
//        }




      //  Thread.sleep(2000000);

        // 判断 getTraceTime是否大于0
        for(File file:new File("D:\\新疆一体化2\\CourseInfoDeal").listFiles()){
            boolean isDelete = false;
         try {
             InputStream inputStream1 = new FileInputStream(file);
             String videoInfoStr = IOUtils.toString(inputStream1, StandardCharsets.UTF_8);
             XjCourseVideoInfo xjCourseVideoInfo = JSONObject.parseObject(videoInfoStr, XjCourseVideoInfo.class);

                 for(XjCourseVideoInfo.ContentDTO contentDTO:xjCourseVideoInfo.getContent()){
                     for(XjCourseVideoInfo.ContentDTO.ResourcesDTO resourcesDTO :contentDTO.getResources()){
                         if(resourcesDTO.getTraceTime()==0){
                             isDelete = true;
                             System.err.println(contentDTO.getName()+"   name111111:"+file.getName());
                         }
                     }
                 }
         }catch (Exception e){
             System.err.println("eeee:"+file.getName());
         }finally {
             if (isDelete){
                 file.deleteOnExit();
             }
         }
        }
        // 判断 getTraceTime是否大于0


        for(File file:new File("D:\\新疆一体化2\\CourseInfoDeal").listFiles()){
            try {
                InputStream inputStream1 = new FileInputStream(file);
                String videoInfoStr = IOUtils.toString(inputStream1, StandardCharsets.UTF_8);
                XjCourseVideoInfo xjCourseVideoInfo = JSONObject.parseObject(videoInfoStr, XjCourseVideoInfo.class);

                System.err.println("name:"+file.getName()+"\t"+"");

                int examinesSize = 0;
                int resourcesSize = 0;
                for(XjCourseVideoInfo.ContentDTO contentDTO:xjCourseVideoInfo.getContent()){
                   examinesSize  = examinesSize+contentDTO.getExamines().size();
                    resourcesSize  = resourcesSize+contentDTO.getResources().size();
                }
              if(resourcesSize>examinesSize+1){
                  System.err.println("name:"+file.getName()+"\t"+"ExaminesSize"+examinesSize+"\t ResourcesSize"+resourcesSize);
              }
            }catch (Exception e){
            }finally {
            }
        }


    }

}
